#pragma once
class Lockable
{
public:
	Lockable(void) { InitializeCriticalSection(&_Section); }
	~Lockable(void) { DeleteCriticalSection(&_Section); }

	void Lock(void) { EnterCriticalSection(&_Section); }
	void Unlock(void) { LeaveCriticalSection(&_Section); }

private:
	CRITICAL_SECTION _Section;
};

class LockThis
{
public:
	LockThis(Lockable * l) { _l = l; l->Lock(); }
	~LockThis() { _l->Unlock(); }
private:
	Lockable * _l;
};

#define LOCKTHIS LockThis _locallock(this);
